<%--
  Created by IntelliJ IDEA.
  User: cyy
  Date: 2022/12/3
  Time: 13:08
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.ArrayList" %>
<%@ taglib prefix="rapid" uri="http://www.rapid-framework.org.cn/rapid" %>
<!DOCTYPE html>
<html>
<head>
    <title>我的个人信息</title>
</head>
<body>
    <rapid:block name="titleContent">
        <h2 align="center" style="left: 30%">我的个人信息</h2>
    </rapid:block>

    <button onclick="clearHistory1()">清空历史记录</button>
    <rapid:block name="mainContent">
        <%if(Integer.parseInt(session.getAttribute("identity").toString())==0){%>
        <div align="center">
            <button onclick="returnToIndex()">回到首页</button>
        </div>
        <%}else{%>
        <div align="center">
            <button onclick="returnToIndex1()">回到首页</button>
        </div>
        <%}%>
        <div class="cart-page">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-md-3">
                        <table class="table table-bordered">
                            <thead class="thead-dark">
                            <tr>
                                <th>登录时间</th>
                            </tr>
                            </thead>
                            <tbody class="align-middle">
                            <%
                                ArrayList<String> loginRecords=(ArrayList<String>)request.getAttribute("loginRecords");
                                if(loginRecords!=null)
                                {
                                    for(int i=0;i<loginRecords.size();i++)
                                    {%>
                            <tr>
                                <td><%=loginRecords.get(i)%></td>
                            </tr>
                            <%}}%>
                            </tbody>
                        </table>
                    </div>
                    <div class="col-md-9">
                        <div class="history-page-inner">
                            <div class="table-responsive">
                                <table class="table table-bordered">
                                    <thead class="thead-dark">
                                        <tr>
                                            <th>用户名</th>
                                            <th>密码</th>
                                            <th>邮箱</th>
                                            <th>注册时间</th>
                                            <%if(Integer.parseInt(session.getAttribute("identity").toString())==0){%>
                                            <th>收货地址</th>
                                            <th>联系方式</th>
                                            <th>修改密码/地址/联系方式</th>
                                            <%}%>
                                        </tr>
                                    </thead>
                                    <tbody class="align-middle">
                                        <td><%=session.getAttribute("name")%></td>
                                        <td><div id="pwdText"><%=request.getAttribute("pwd")%></div></td>
                                        <td><%=request.getAttribute("email")%></td>
                                        <td><%=request.getAttribute("registerTime")%></td>
<%--                                        根据身份来决定是否需要呈现地址等信息（顾客有，售货员没有）--%>
                                        <%if(Integer.parseInt(session.getAttribute("identity").toString())==0){%>
                                            <td><div id="addressText"><%=request.getAttribute("address")%></div></td>
                                            <td><div id="phoneText"><%=request.getAttribute("phone")%></div></td>
                                        <td>
<%--                                            编辑按钮被点击时，原本的编辑图标会变成两个按钮，一个保存，一个取消--%>
                                            <button id="editBt" style="display:inline-block" onclick="edit('<%=request.getAttribute("address")%>','<%=request.getAttribute("phone")%>','<%=request.getAttribute("pwd")%>')">
                                                <i class="fa fa-edit" style="color: #17a2b8"></i>
                                            </button>
                                            <button id="editBtYes" class="hiddenBt1" onclick="save()" style="width: auto">保存</button>
                                            <button id="editBtNo" class="hiddenBt" onclick="cancel('<%=request.getAttribute("address")%>','<%=request.getAttribute("phone")%>','<%=request.getAttribute("pwd")%>')" style="width: auto">取消</button>
                                        </td>
                                        <%}%>
                                    </tbody>
                              </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </rapid:block>
    <%@ include file="customerProductIndex.jsp"%>
</body>
</html>
